//
//  ModalViewController.m
//  OCIOSDemo
//
//  Created by Caldremch on 2018/5/28.
//  Copyright © 2018年 Caldremch. All rights reserved.
//

#import "ModalViewController.h"

@interface ModalViewController ()

@end

@implementation ModalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor orangeColor];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
       CGSize s =  [UIScreen mainScreen].bounds.size;
    
    button.backgroundColor = [UIColor redColor];
    
    button.frame = CGRectMake(s.width/2 -140/2, s.height/2-40/2, 140, 40);
    
    
    [button setTitle:@"diss" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
    
    _textField = [[UITextField alloc] initWithFrame:CGRectMake(s.width/2 -140/2, s.height/4, 140, 40)];
    
    _textField.borderStyle = UITextBorderStyleRoundedRect;
    
    [self.view addSubview:_textField];
    
    [self.view addSubview:button];
    
    
}

- (void) dismiss {
    
    
    if ([self.delegate respondsToSelector:@selector(changeLabelText:)]) {
        [self.delegate changeLabelText:_textField.text];
    }
    
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
